import React from 'react'
// import axios from 'axios'
export default class FetchUser extends React.Component {
  state = {
    user: {},
  }
  
  componentDidMount() {
     // axios获取用户的数据
    //     axios.get('https://xiaozhu.run/api/user/9527').then(()=>{
    //         console.log(`resp`,resp)
    //     });
    // fetch方式获取设置用户
    fetch('https://xiaozhu.run/api/user/9527').then((r) => {
      r.json().then((resp) => {
        this.setState({ user: resp.data })
        console.log(`resp`, resp)
      })
    })
  }
  render() {
    const { user } = this.state
    return <div>Username:{user.username}</div>
  }
}

